<html>
 <head>
  <meta charset="utf-8"/>
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"/>
  <title>
   《面向程序员的数据挖掘指南》——（三）隐式评价和基于物品的过滤算法  | 数螺 | NAUT IDEA
  </title>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" rel="stylesheet"/>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
  <style type="text/css">
   #xmain img {
                  max-width: 100%;
                  display: block;
                  margin-top: 10px;
                  margin-bottom: 10px;
                }

                #xmain p {
                    line-height:150%;
                    font-size: 16px;
                    margin-top: 20px;
                }

                #xmain h2 {
                    font-size: 24px;
                }

                #xmain h3 {
                    font-size: 20px;
                }

                #xmain h4 {
                    font-size: 18px;
                }


                .header {
	           background-color: #0099ff;
	           color: #ffffff;
	           margin-bottom: 20px;
	        }

	        .header p {
                  margin: 0px;
                  padding: 10px 0;
                  display: inline-block;  
                  vertical-align: middle;
                  font-size: 16px;
               }

               .header a {
                 color: white;
               }

              .header img {
                 height: 25px;
              }
  </style>
  <script src="http://cdn.bootcss.com/jquery/3.0.0/jquery.min.js">
  </script>
  <script src="http://nautstatic-10007657.file.myqcloud.com/static/css/readability.min.js" type="text/javascript">
  </script>
  <script type="text/javascript">
   $(document).ready(function() {
                 var loc = document.location;
                 var uri = {
                  spec: "http://dataunion.org/8082.html",
                  host: "http://dataunion.org",
                  prePath: "http://dataunion.org",
                  scheme: "http",
                  pathBase: "http://dataunion.org/"
                 };
    
                 var documentClone = document.cloneNode(true);
                 var article = new Readability(uri, documentClone).parse();
     
                 document.getElementById("xmain").innerHTML = article.content;
                });
  </script>
  <!-- 1466457535: Accept with keywords: (title(0.222222222222):指南,社区,数盟,物品,程序员,算法,面向,数据挖掘,评价, topn(0.366666666667):指南,数盟,程序员,推荐系统,数据挖掘,协同,Python,模型,电影,歌手,例子,面向,计算,文章,物品,评价,数据,预测,记录,评分,公式,差异,用户,算法,遍历,分母,分数,商品,亚马逊,差值).-->
 </head>
 <body onload="">
  <div class="header">
   <div class="container">
    <div class="row">
     <div class="col-xs-6 col-sm-6 text-left">
      <a href="/databee">
       <img src="http://nautidea-10007657.cos.myqcloud.com/logo_white.png"/>
      </a>
      <a href="/databee">
       <p>
        数螺
       </p>
      </a>
     </div>
     <div class="hidden-xs col-sm-6 text-right">
      <p>
       致力于数据科学的推广和知识传播
      </p>
     </div>
    </div>
   </div>
  </div>
  <div class="container text-center">
   <h1>
    《面向程序员的数据挖掘指南》——（三）隐式评价和基于物品的过滤算法
   </h1>
  </div>
  <div class="container" id="xmain">
   ﻿﻿
   <title>
    《面向程序员的数据挖掘指南》——（三）隐式评价和基于物品的过滤算法 | 数盟社区
   </title>
   <!-- All in One SEO Pack 2.2.7.6.2 by Michael Torbert of Semper Fi Web Design[32,80] -->
   <!-- /all in one seo pack -->
   <!--
<div align="center">
<a href="http://strata.oreilly.com.cn/hadoop-big-data-cn?cmp=mp-data-confreg-home-stcn16_dataunion_pc" target="_blank"><img src="http://dataunion.org/wp-content/uploads/2016/05/stratabj.jpg"/ ></a>
</div>
-->
   <header id="header-web">
    <div class="header-main">
     <hgroup class="logo">
      <h1>
       <a href="http://dataunion.org/" rel="home" title="数盟社区">
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/logo.png"/>
       </a>
      </h1>
     </hgroup>
     <!--logo-->
     <nav class="header-nav">
      <ul class="menu" id="menu-%e4%b8%bb%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-71" id="menu-item-71">
        <a href="http://dataunion.org/category/events" title="events">
         活动
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22457" id="menu-item-22457">
          <a href="http://dataunion.org/2016timeline">
           2016档期
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22459" id="menu-item-22459">
          <a href="http://dataunion.org/category/parterc">
           合作会议
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor menu-item-has-children menu-item-20869" id="menu-item-20869">
        <a href="http://dataunion.org/category/tech" title="articles">
         文章
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20867" id="menu-item-20867">
          <a href="http://dataunion.org/category/tech/base" title="base">
           基础架构
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3302" id="menu-item-3302">
          <a href="http://dataunion.org/category/tech/ai" title="ai">
           人工智能
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor current-menu-parent current-post-parent menu-item-3303" id="menu-item-3303">
          <a href="http://dataunion.org/category/tech/analysis" title="analysis">
           数据分析
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21920" id="menu-item-21920">
          <a href="http://dataunion.org/category/tech/dm">
           数据挖掘
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3314" id="menu-item-3314">
          <a href="http://dataunion.org/category/tech/viz" title="viz">
           可视化
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3305" id="menu-item-3305">
          <a href="http://dataunion.org/category/tech/devl" title="devl">
           编程语言
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-20876" id="menu-item-20876">
        <a href="http://dataunion.org/category/industry">
         行业
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-16328" id="menu-item-16328">
          <a href="http://dataunion.org/category/industry/case" title="case">
           行业应用
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-2112" id="menu-item-2112">
          <a href="http://dataunion.org/category/industry/demo" title="demo">
           Demo展示
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21562" id="menu-item-21562">
          <a href="http://dataunion.org/category/industry/news">
           行业资讯
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-311" id="menu-item-311">
        <a href="http://dataunion.org/category/sources" title="sources">
         资源
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20870" id="menu-item-20870">
        <a href="http://dataunion.org/category/books" title="book">
         图书
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21363" id="menu-item-21363">
        <a href="http://dataunion.org/category/training">
         课程
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-21853" id="menu-item-21853">
        <a href="http://dataunion.org/category/jobs">
         职位
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22050" id="menu-item-22050">
          <a href="http://dataunion.org/category/career">
           职业规划
          </a>
         </li>
        </ul>
       </li>
      </ul>
     </nav>
     <!--header-nav-->
    </div>
   </header>
   <!--header-web-->
   <div id="main">
    <div id="soutab">
     <form action="http://dataunion.org/" class="search" method="get">
     </form>
    </div>
    <div id="container">
     <nav id="mbx">
      当前位置：
      <a href="http://dataunion.org">
       首页
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech">
       文章
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech/analysis">
       数据分析
      </a>
      &gt;  正文
     </nav>
     <!--mbx-->
     <article class="content">
      <header align="centre" class="contenttitle">
       <div class="mscc">
        <h1 class="mscctitle">
         <a href="http://dataunion.org/8082.html">
          《面向程序员的数据挖掘指南》——（三）隐式评价和基于物品的过滤算法
         </a>
        </h1>
        <address class="msccaddress ">
         <em>
          3,152 次阅读 -
         </em>
         <a href="http://dataunion.org/category/tech/analysis" rel="category tag">
          数据分析
         </a>
        </address>
       </div>
      </header>
      <div class="content-text">
       <p>
        翻译：
        <a data-original-title="" href="https://github.com/jizhang" rel="author" title="">
         jizhang
        </a>
       </p>
       <p>
        本章会从用户的评价类型开始讨论，包括显式评价（赞一下、踩一脚、五星评价等等）和隐式评价（比如在亚马逊上购买了MP3，我们可以认为他喜欢这个产品）。
       </p>
       <blockquote>
        <p>
         <a data-original-title="" href="http://dataunion.org/?p=7965" title="">
          《面向程序员的数据挖掘指南》——（一）简介：数据挖掘是什么
         </a>
        </p>
        <p>
         <a data-original-title="" href="http://dataunion.org/?p=7989" title="">
          《面向程序员的数据挖掘指南》——（二）推荐系统入门
         </a>
        </p>
        <p>
         <a data-original-title="" href="http://dataunion.org/?p=8082" title="">
          《面向程序员的数据挖掘指南》——（三）隐式评价和基于物品的过滤算法
         </a>
        </p>
        <p>
         <a data-original-title="" href="http://dataunion.org/?p=8137" title="">
          《面向程序员的数据挖掘指南》——（四）分类
         </a>
        </p>
        <p>
         <a data-original-title="" href="http://dataunion.org/?p=8591" title="">
          《面向程序员的数据挖掘指南》——（五）进一步探索分类
         </a>
        </p>
        <p>
         <a href="http://dataunion.org/?p=8660">
          《面向程序员的数据挖掘指南》——（六）朴素贝叶斯和概率
         </a>
        </p>
        <p>
         <a href="http://dataunion.org/?p=8895">
          《面向程序员的数据挖掘指南》——（七）朴素贝叶斯和文本数据
         </a>
        </p>
        <p>
         <a href="http://dataunion.org/?p=9401">
          《面向程序员的数据挖掘指南》——（八）聚类
         </a>
        </p>
       </blockquote>
       <p>
        内容：
       </p>
       <ul class="task-list">
        <li>
         显式评价
        </li>
        <li>
         隐式评价
        </li>
        <li>
         哪种评价方式更准确？
        </li>
        <li>
         基于用户的协同过滤
        </li>
        <li>
         基于物品的协同过滤
        </li>
        <li>
         修正的余弦相似度
        </li>
        <li>
         Slope One算法
        </li>
        <li>
         Slope One的Python实现
        </li>
        <li>
         MovieLens数据
        </li>
       </ul>
       <p>
        第二章中我们学习了协同过滤和推荐系统的基本知识，其中讲述的算法是比较通用的，可以适用于多种数据集。用户使用5到10分的标尺来对不同的物品进行打分，通过计算得到相似的用户。但是，也有迹象表明用户通常不会有效地使用这种度量方式，而更倾向于给出极好或极差的评价，这种做法会使推荐结果变得不可用。这一章我们将继续探讨这个问题，尝试使用高效的方法给出更精确的推荐。
       </p>
       <h2>
        <a class="anchor" href="https://github.com/jizhang/guidetodatamining/blob/master/chapter-3.md#%E6%98%BE%E5%BC%8F%E8%AF%84%E4%BB%B7" id="user-content-显式评价">
        </a>
        显式评价
       </h2>
       <p>
        用户的评价类型可以分为显式评价和隐式评价。显式评价指的是用户明确地给出对物品的评价，最常见的例子是Pandora和YouTube上的“喜欢”和“不喜欢”按钮：
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-1.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-1.png"/>
        </a>
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-2.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-2.png"/>
        </a>
       </p>
       <p>
        以及亚马逊的星级系统：
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-3.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-3.png"/>
        </a>
       </p>
       <h2>
        <a class="anchor" href="https://github.com/jizhang/guidetodatamining/blob/master/chapter-3.md#%E9%9A%90%E5%BC%8F%E8%AF%84%E4%BB%B7" id="user-content-隐式评价">
        </a>
        隐式评价
       </h2>
       <p>
        所谓隐式评价，就是我们不让用户明确给出对物品的评价，而是通过观察他们的行为来获得偏好信息。示例之一是记录用户在纽约时报网上的点击记录。
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-4.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-4.png"/>
        </a>
       </p>
       <p>
        经过几周的观察之后，我们就可以为用户刻画出一个合理的模型了——她不喜欢体育新闻，但关注科技新闻；如果用户连续看了两篇文章：《快速减肥方法》和《不反弹的减肥方式》，那她很可能正在减肥；如果她点击了iPhone的广告，就表明她或许对这款产品感兴趣。
       </p>
       <p>
        试想一下，如果我们记录了用户在亚马逊上的操作记录，可以得出一些什么结论。你的首页上可能有这样的内容：
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-5.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-5.png"/>
        </a>
       </p>
       <p>
        在这个示例中，亚马逊记录了用户的点击操作，因此它会知道浏览了Jupter Travel这本书的用户还浏览了Long Way Round这部DVD，其详细记录了演员伊万环球骑行的旅程。因此，亚马逊就用这些信息来做出“看过还看过”的推荐。
       </p>
       <p>
        另一种隐式评价是用户的实际购买记录，亚马逊也会用这些记录来进行“买过还买过”、以及“看过此商品的用户还买过”的推荐。
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-6.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-6.png"/>
        </a>
       </p>
       <p>
        可能你会觉得“买过还买过”应该会给出一些不合理的推荐结果，但事实上它运作得很好。
       </p>
       <p>
        再来看看iTunes上如何记录用户的行为：
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-7.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-7.png"/>
        </a>
       </p>
       <p>
        首先，我将一首歌添加到了iTunes，这至少表明我对这首歌是感兴趣的。然后是播放次数，上表中我听了Anchor这首歌52次，说明我很喜欢；而那些只听了一次的歌曲则是我不喜欢的。
       </p>
       <p>
        <strong>
         头脑风暴
        </strong>
       </p>
       <blockquote>
        <p>
         你觉得让用户对物品进行显式评价会更精确吗？还是说通过观察用户对物品的行为（是否购买或播放次数）才更为准确？
        </p>
       </blockquote>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-8.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-8.png"/>
        </a>
       </p>
       <blockquote>
        <p>
         显式评价：我叫吉姆，是一个素食主义者。我爱喝葡萄酒，喜欢在森林中漫步，在篝火旁阅读Chekov的书，喜欢观看法国电影，周六会去艺术博物馆逛逛，我还喜欢舒曼的钢琴曲。
        </p>
       </blockquote>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-9.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-9.png"/>
        </a>
       </p>
       <blockquote>
        <p>
         隐式评价：我们在吉姆的口袋里发现了12打美国蓝带啤酒的收银条，以及冰激淋、披萨和甜甜圈的收银条。还有一些租借DVD的回执，有复仇者联盟、生化危机、拳霸等。
        </p>
       </blockquote>
       <h2>
        <a class="anchor" href="https://github.com/jizhang/guidetodatamining/blob/master/chapter-3.md#%E6%98%BE%E5%BC%8F%E8%AF%84%E4%BB%B7%E7%9A%84%E9%97%AE%E9%A2%98" id="user-content-显式评价的问题">
        </a>
        显式评价的问题
       </h2>
       <h3>
        <a class="anchor" href="https://github.com/jizhang/guidetodatamining/blob/master/chapter-3.md#%E9%97%AE%E9%A2%981%E4%BA%BA%E4%BB%AC%E5%BE%88%E6%87%92%E4%B8%8D%E6%84%BF%E8%AF%84%E4%BB%B7%E7%89%A9%E5%93%81" id="user-content-问题1人们很懒不愿评价物品">
        </a>
        问题1：人们很懒，不愿评价物品
       </h3>
       <p>
        首先，用户很可能不会对物品做出评价。相信各位读者已经在亚马逊上购买了很多商品，就拿我来说，仅过去一个月我就在那里购买了直升机模型、1TB硬盘、USB-SATA转接头、维他命药片、两本Kindle电子书、四本纸质书。一共十件商品，我评价了几件？零件！相信很多人和我是一样的——我们不评价商品，我们只管买。
       </p>
       <p>
        我喜欢旅行和登山，所以购买了很多登山杖。亚马逊上一些价格实惠的登山杖很耐用。去年我到奥斯汀市参加音乐会，途中碰坏了膝盖，于是到REI专营店买了一根价格昂贵的登山杖。不过这根杖居然在我逛公园时用断了！这根昂贵的登山杖还没有买的10美元的来得结实。放假时，我打算给这件商品写一篇评价，告诫其他购买者。结果呢？我没有写，因为我太懒了。
       </p>
       <h3>
        <a class="anchor" href="https://github.com/jizhang/guidetodatamining/blob/master/chapter-3.md#%E9%97%AE%E9%A2%982%E4%BA%BA%E4%BB%AC%E4%BC%9A%E6%92%92%E8%B0%8E%E6%88%96%E5%AD%98%E6%9C%89%E5%81%8F%E8%A7%81" id="user-content-问题2人们会撒谎或存有偏见">
        </a>
        问题2：人们会撒谎，或存有偏见
       </h3>
       <p>
        我们假设有人不像前面说得那么懒，确实去给物品做出评价了，但他有可能会撒谎。这种情况在前文中已经有提到了。用户可能会直接撒谎，给出不正确的评价；或是不置可否，抱有偏见。Ben和他的朋友们去看了一场泰国出的电影，Ben认为这部电影很糟糕，而其他人却觉得很好看，在餐厅里欢快地谈论着。于是，Ben在评价电影时很有可能会抬高它的分数，这样才能表现得合群。
       </p>
       <h3>
        <a class="anchor" href="https://github.com/jizhang/guidetodatamining/blob/master/chapter-3.md#%E9%97%AE%E9%A2%983%E4%BA%BA%E4%BB%AC%E4%B8%8D%E4%BC%9A%E6%9B%B4%E6%96%B0%E4%BB%96%E4%BB%AC%E7%9A%84%E8%AF%84%E8%AE%BA" id="user-content-问题3人们不会更新他们的评论">
        </a>
        问题3：人们不会更新他们的评论
       </h3>
       <p>
        假设我去亚马逊评价了商品——那个1TB的硬盘速度很快也很静音；直升机模型操作起来也很简便，不容易摔坏。所以这两件商品我都给出了5星的评价。但一个月后，那块硬盘坏了，我丢失了所有的电影和音乐；那台直升机模型也突然不再工作了，让我非常扫兴。但是，我不太会返回亚马逊网站对这两件商品的评价做出改动，这样人们依旧认为我是非常喜欢这两件商品的。
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-10.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-10.png"/>
        </a>
       </p>
       <p>
        再举一个示例，玛丽很乐意在亚马逊上对商品做评价。她十年前给一些儿童类书籍打了很高的分数，近些年又对一些摇滚乐队的专辑给出了评价。从近年的评价看，她和另一位用户珍妮很相似。但是，如果我们把那些儿童书籍推荐给珍妮就显得不合适了。这个例子和上面的有些不同，但的确是个问题。
       </p>
       <p>
        <strong>
         头脑风暴
        </strong>
       </p>
       <blockquote>
        <p>
         你觉得隐式评价会有什么问题？提示：可以回忆一下你在亚马逊的购买记录。
        </p>
       </blockquote>
       <p>
        上文中我给出了一个近期在亚马逊上的购物列表，其中有两样是我买来送给其他人的。为什么这会是一个问题？我再举一些其他的例子。我给我的孩子买了一个壶铃和一本关于健身的书籍；我给我的太太买了一个边境牧羊犬的毛绒玩具，因为我家那只14岁大的狗去世了。通过隐式评价来进行建模，会让你觉得我喜欢壶铃和毛绒玩具。亚马逊的购买记录无法区分这件商品是我买来自己用的还是送人的。贝克也曾给出了相似的例子：
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-11.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-11.png"/>
        </a>
       </p>
       <blockquote>
        <p>
         对于计算机来说，能够将白色连衣裙和婴儿潮出生的女性关联起来是任务的第一步，然后再对这些用户建立模型。假设我的太太在商店里购买了几件商品：内衣、裤子、连衣裙、皮带等，这些商品都很符合婴儿潮的特点。离开时她想起要为自己16岁大的外甥女买一件生日礼物。由于我们上次看到她时她穿着一件黑色的T恤，上面写满了文字，并自称是一名哥特摇滚妞。于是，我的太太就去买了一根项圈准备送给她。
        </p>
       </blockquote>
       <p>
        可以想象，如果我们要为这位用户构建模型，那这根项圈的存在就很有问题了。
       </p>
       <p>
        再比如一对情侣使用的是同一个Netflix账号。男方喜欢各种爆破场面，女方则喜欢知性类型的电影。如果我们从浏览历史进行挖掘，则会发现一个人会喜欢两种截然不同的影片类型。
       </p>
       <p>
        前面说到我买了一些书给别人，所以单从购买历史看，同一本书我会购买很多次。这样有两种可能：一是我的书不小心丢了，二是我得了老年痴呆，不记得自己曾读过这些书。而事实是我非常喜欢这些书，因此多买了几本作为礼物来送给别人。所以说，用户的购买记录还是非常值得深究的。
       </p>
       <p>
        <strong>
         头脑风暴
        </strong>
       </p>
       <blockquote>
        <p>
         我们可以收集到哪些隐式评价呢？ 网页方面：页面点击、停留时间、重复访问次数、引用率、Hulu上观看视频的次数； 音乐播放器：播放的曲目、跳过的曲目、播放次数； 这些只是一小部分！
        </p>
       </blockquote>
       <p>
        值得注意的是，我们在第二章中学习的算法对于显式评价和隐式评价都是适用的。
       </p>
       <h2>
        <a class="anchor" href="https://github.com/jizhang/guidetodatamining/blob/master/chapter-3.md#%E4%BB%80%E4%B9%88%E4%BC%9A%E9%98%BB%E7%A2%8D%E4%BD%A0%E6%88%90%E5%8A%9F" id="user-content-什么会阻碍你成功">
        </a>
        什么会阻碍你成功？
       </h2>
       <p>
        设想你有一个成熟的在线音乐网站，在构建推荐系统时会遇到什么问题呢？
       </p>
       <p>
        假设你有一百万个用户，每次推荐需要计算一百万个距离数据。如果我们想在一秒钟里进行多次推荐，那计算量将是巨大的。除非增加服务器的数量，否则系统会变得越来越慢。说得专业一点，通过邻域进行计算的推荐系统，延迟会变得越来越严重。还好，这是有解决办法的。
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-12.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-12.png"/>
        </a>
       </p>
       <h2>
        <a class="anchor" href="https://github.com/jizhang/guidetodatamining/blob/master/chapter-3.md#%E5%9F%BA%E4%BA%8E%E7%94%A8%E6%88%B7%E7%9A%84%E5%8D%8F%E5%90%8C%E8%BF%87%E6%BB%A4" id="user-content-基于用户的协同过滤">
        </a>
        基于用户的协同过滤
       </h2>
       <p>
        目前为止我们描述的都是基于用户的协同过滤算法。我们将一个用户和其他所有用户进行对比，找到相似的人。这种算法有两个弊端：
       </p>
       <ol class="task-list">
        <li>
         <strong>
          扩展性
         </strong>
         上文已经提到，随着用户数量的增加，其计算量也会增加。这种算法在只有几千个用户的情况下能够工作得很好，但达到一百万个用户时就会出现瓶颈。
        </li>
        <li>
         <strong>
          稀疏性
         </strong>
         大多数推荐系统中，物品的数量要远大于用户的数量，因此用户仅仅对一小部分物品进行了评价，这就造成了数据的稀疏性。比如亚马逊有上百万本书，但用户只评论了很少一部分，于是就很难找到两个相似的用户了。
        </li>
       </ol>
       <p>
        鉴于以上两个局限性，我们不妨考察一下基于物品的协同过滤算法。
       </p>
       <h2>
        <a class="anchor" href="https://github.com/jizhang/guidetodatamining/blob/master/chapter-3.md#%E5%9F%BA%E4%BA%8E%E7%89%A9%E5%93%81%E7%9A%84%E5%8D%8F%E5%90%8C%E8%BF%87%E6%BB%A4" id="user-content-基于物品的协同过滤">
        </a>
        基于物品的协同过滤
       </h2>
       <p>
        假设我们有一种算法可以计算出两件物品之间的相似度，比如Phoenix专辑和Manners很相似。如果一个用户给Phoenix打了很高的分数，我们就可以向他推荐Manners了。需要注意这两种算法的区别：基于用户的协同过滤是通过计算用户之间的距离找出最相似的用户，并将他评价过的物品推荐给目标用户；而基于物品的协同过滤则是找出最相似的物品，再结合用户的评价来给出推荐结果。
       </p>
       <h3>
        <a class="anchor" href="https://github.com/jizhang/guidetodatamining/blob/master/chapter-3.md#%E8%83%BD%E5%90%A6%E4%B8%BE%E4%B8%AA%E4%BE%8B%E5%AD%90" id="user-content-能否举个例子">
        </a>
        能否举个例子？
       </h3>
       <p>
        我们的音乐站点有m个用户和n个乐队，用户会对乐队做出评价，如下表所示：
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-13.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-13.png"/>
        </a>
       </p>
       <p>
        我们要计算Phoenix和Passion Pit之间的相似度，可以使用蓝色方框中的数据，也就是同时对这两件商品都有过评价的用户。在基于用户的算法中，我们计算的是行与行之间的相似度，而在基于物品的算法中，我们计算的是列与列之间的。
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-14.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-14.png"/>
        </a>
       </p>
       <blockquote>
        <p>
         基于用户的协同过滤又称为内存型协同过滤，因为我们需要将所有的评价数据都保存在内存中来进行推荐。
        </p>
        <p>
         基于物品的协同过滤也称为基于模型的协同过滤，因为我们不需要保存所有的评价数据，而是通过构建一个物品相似度模型来做推荐。
        </p>
       </blockquote>
       <h2>
        <a class="anchor" href="https://github.com/jizhang/guidetodatamining/blob/master/chapter-3.md#%E4%BF%AE%E6%AD%A3%E7%9A%84%E4%BD%99%E5%BC%A6%E7%9B%B8%E4%BC%BC%E5%BA%A6" id="user-content-修正的余弦相似度">
        </a>
        修正的余弦相似度
       </h2>
       <p>
        我们使用余弦相似度来计算两个物品的距离。我们在第二章中提过“分数膨胀”现象，因此我们会从用户的评价中减去他所有评价的均值，这就是修正的余弦相似度。
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-15.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-15.png"/>
        </a>
       </p>
       <blockquote>
        <p>
         左：我喜欢Phoenix乐队，因此给他们打了5分。我不喜欢Passion，所以给了3分。
        </p>
        <p>
         右：Phoenix很棒，我给4分。Passion Pit太糟糕了，必须给0分！
        </p>
       </blockquote>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-16.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-16.png"/>
        </a>
       </p>
       <p>
        <em>
         U表示同时评价过物品i和j的用户集合
        </em>
       </p>
       <p>
        这个公式来自于一篇影响深远的论文《
        <a href="http://www.grouplens.org/papers/pdf/www10_sarwar.pdf">
         基于物品的协同过滤算法
        </a>
        》，由Badrul Sarwar等人合著。
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-17.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-17.png"/>
        </a>
       </p>
       <p>
        上式表示将用户u对物品i的评价值减去用户u对所有物品的评价均值，从而得到修正后的评分。s(i,j)表示物品i和j的相似度，分子表示将同时评价过物品i和j的用户的修正评分相乘并求和，分母则是对所有的物品的修正评分做一些汇总处理。
       </p>
       <p>
        为了更好地演示修正的余弦相似度，我们举一个例子。下表是五个学生对五位歌手的评价：
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-18.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-18.png"/>
        </a>
       </p>
       <p>
        首先，我们计算出每个用户的平均评分，这很简单：
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-19.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-19.png"/>
        </a>
       </p>
       <p>
        下面，我们计算歌手之间的相似度，从Kacey Musgraves和Imagine Dragons开始。上图中我已经标出了同时评价过这两个歌手的用户，代入到公式中：
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-20.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-20.png"/>
        </a>
       </p>
       <p>
        所以这两个歌手之间的修正余弦相似度为0.5260，我计算了其他一些歌手之间的相似度，其余的请读者们完成：
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-21.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-21.png"/>
        </a>
       </p>
       <h3>
        <a class="anchor" href="https://github.com/jizhang/guidetodatamining/blob/master/chapter-3.md#%E8%AE%A1%E7%AE%97%E4%BF%AE%E6%AD%A3%E4%BD%99%E5%BC%A6%E7%9B%B8%E4%BC%BC%E5%BA%A6%E7%9A%84python%E4%BB%A3%E7%A0%81" id="user-content-计算修正余弦相似度的python代码">
        </a>
        计算修正余弦相似度的Python代码
       </h3>
       <div class="highlight highlight-python">
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685db75c8dd324701569" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           &lt;span class="pl-c"&gt;# -*- coding: utf-8 -*-&lt;/span&gt;

&lt;span class="pl-k"&gt;from&lt;/span&gt; math &lt;span class="pl-k"&gt;import&lt;/span&gt; sqrt

users3 &lt;span class="pl-k"&gt;=&lt;/span&gt; {&lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;David&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: {&lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Imagine Dragons&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;3&lt;/span&gt;, &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Daft Punk&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;5&lt;/span&gt;,
                    &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Lorde&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;4&lt;/span&gt;, &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Fall Out Boy&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;1&lt;/span&gt;},
          &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Matt&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: {&lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Imagine Dragons&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;3&lt;/span&gt;, &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Daft Punk&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;4&lt;/span&gt;,
                   &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Lorde&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;4&lt;/span&gt;, &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Fall Out Boy&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;1&lt;/span&gt;},
          &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Ben&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: {&lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Kacey Musgraves&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;4&lt;/span&gt;, &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Imagine Dragons&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;3&lt;/span&gt;,
                  &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Lorde&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;3&lt;/span&gt;, &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Fall Out Boy&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;1&lt;/span&gt;},
          &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Chris&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: {&lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Kacey Musgraves&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;4&lt;/span&gt;, &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Imagine Dragons&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;4&lt;/span&gt;,
                    &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Daft Punk&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;4&lt;/span&gt;, &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Lorde&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;3&lt;/span&gt;, &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Fall Out Boy&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;1&lt;/span&gt;},
          &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Tori&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: {&lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Kacey Musgraves&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;5&lt;/span&gt;, &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Imagine Dragons&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;4&lt;/span&gt;,
                   &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Daft Punk&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;5&lt;/span&gt;, &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Fall Out Boy&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;3&lt;/span&gt;}}


&lt;span class="pl-st"&gt;def&lt;/span&gt; &lt;span class="pl-en"&gt;computeSimilarity&lt;/span&gt;(&lt;span class="pl-vpf"&gt;band1&lt;/span&gt;, &lt;span class="pl-vpf"&gt;band2&lt;/span&gt;, &lt;span class="pl-vpf"&gt;userRatings&lt;/span&gt;):
    averages &lt;span class="pl-k"&gt;=&lt;/span&gt; {}
    &lt;span class="pl-k"&gt;for&lt;/span&gt; (key, ratings) &lt;span class="pl-k"&gt;in&lt;/span&gt; userRatings.items():
        averages[key] &lt;span class="pl-k"&gt;=&lt;/span&gt; (&lt;span class="pl-s3"&gt;float&lt;/span&gt;(&lt;span class="pl-s3"&gt;sum&lt;/span&gt;(ratings.values())) &lt;span class="pl-k"&gt;/&lt;/span&gt; &lt;span class="pl-s3"&gt;len&lt;/span&gt;(ratings.values()))

    num &lt;span class="pl-k"&gt;=&lt;/span&gt; &lt;span class="pl-c1"&gt;0&lt;/span&gt; &lt;span class="pl-c"&gt;# 分子&lt;/span&gt;
    dem1 &lt;span class="pl-k"&gt;=&lt;/span&gt; &lt;span class="pl-c1"&gt;0&lt;/span&gt; &lt;span class="pl-c"&gt;# 分母的第一部分&lt;/span&gt;
    dem2 &lt;span class="pl-k"&gt;=&lt;/span&gt; &lt;span class="pl-c1"&gt;0&lt;/span&gt;
    &lt;span class="pl-k"&gt;for&lt;/span&gt; (user, ratings) &lt;span class="pl-k"&gt;in&lt;/span&gt; userRatings.items():
        &lt;span class="pl-k"&gt;if&lt;/span&gt; band1 &lt;span class="pl-k"&gt;in&lt;/span&gt; ratings &lt;span class="pl-k"&gt;and&lt;/span&gt; band2 &lt;span class="pl-k"&gt;in&lt;/span&gt; ratings:
            avg &lt;span class="pl-k"&gt;=&lt;/span&gt; averages[user]
            num &lt;span class="pl-k"&gt;+=&lt;/span&gt; (ratings[band1] &lt;span class="pl-k"&gt;-&lt;/span&gt; avg) &lt;span class="pl-k"&gt;*&lt;/span&gt; (ratings[band2] &lt;span class="pl-k"&gt;-&lt;/span&gt; avg)
            dem1 &lt;span class="pl-k"&gt;+=&lt;/span&gt; (ratings[band1] &lt;span class="pl-k"&gt;-&lt;/span&gt; avg) &lt;span class="pl-k"&gt;**&lt;/span&gt; &lt;span class="pl-c1"&gt;2&lt;/span&gt;
            dem2 &lt;span class="pl-k"&gt;+=&lt;/span&gt; (ratings[band2] &lt;span class="pl-k"&gt;-&lt;/span&gt; avg) &lt;span class="pl-k"&gt;**&lt;/span&gt; &lt;span class="pl-c1"&gt;2&lt;/span&gt;
    &lt;span class="pl-k"&gt;return&lt;/span&gt; num &lt;span class="pl-k"&gt;/&lt;/span&gt; (sqrt(dem1) &lt;span class="pl-k"&gt;*&lt;/span&gt; sqrt(dem2))

&lt;span class="pl-k"&gt;print&lt;/span&gt; computeSimilarity(&lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;'&lt;/span&gt;Kacey Musgraves&lt;span class="pl-pds"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;'&lt;/span&gt;Lorde&lt;span class="pl-pds"&gt;'&lt;/span&gt;&lt;/span&gt;, users3)
&lt;span class="pl-k"&gt;print&lt;/span&gt; computeSimilarity(&lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;'&lt;/span&gt;Imagine Dragons&lt;span class="pl-pds"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;'&lt;/span&gt;Lorde&lt;span class="pl-pds"&gt;'&lt;/span&gt;&lt;/span&gt;, users3)
&lt;span class="pl-k"&gt;print&lt;/span&gt; computeSimilarity(&lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;'&lt;/span&gt;Daft Punk&lt;span class="pl-pds"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;'&lt;/span&gt;Lorde&lt;span class="pl-pds"&gt;'&lt;/span&gt;&lt;/span&gt;, users3)
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685db75c8dd324701569-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c8dd324701569-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c8dd324701569-3">
                3
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c8dd324701569-4">
                4
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c8dd324701569-5">
                5
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c8dd324701569-6">
                6
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c8dd324701569-7">
                7
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c8dd324701569-8">
                8
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c8dd324701569-9">
                9
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c8dd324701569-10">
                10
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c8dd324701569-11">
                11
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c8dd324701569-12">
                12
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c8dd324701569-13">
                13
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c8dd324701569-14">
                14
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c8dd324701569-15">
                15
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c8dd324701569-16">
                16
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c8dd324701569-17">
                17
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c8dd324701569-18">
                18
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c8dd324701569-19">
                19
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c8dd324701569-20">
                20
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c8dd324701569-21">
                21
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c8dd324701569-22">
                22
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c8dd324701569-23">
                23
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c8dd324701569-24">
                24
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c8dd324701569-25">
                25
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c8dd324701569-26">
                26
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c8dd324701569-27">
                27
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c8dd324701569-28">
                28
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c8dd324701569-29">
                29
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c8dd324701569-30">
                30
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c8dd324701569-31">
                31
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c8dd324701569-32">
                32
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c8dd324701569-33">
                33
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c8dd324701569-34">
                34
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c8dd324701569-35">
                35
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685db75c8dd324701569-1">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # -*- coding: utf-8 -*-&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c8dd324701569-2">
               </div>
               <div class="crayon-line" id="crayon-57685db75c8dd324701569-3">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 from
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 math
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 import
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 sqrt
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c8dd324701569-4">
               </div>
               <div class="crayon-line" id="crayon-57685db75c8dd324701569-5">
                <span class="crayon-v">
                 users3
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;David&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Imagine Dragons&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 3
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Daft Punk&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 5
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c8dd324701569-6">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Lorde&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 4
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Fall Out Boy&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 }
                </span>
                <span class="crayon-sy">
                 ,
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c8dd324701569-7">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Matt&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Imagine Dragons&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 3
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Daft Punk&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 4
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c8dd324701569-8">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Lorde&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 4
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Fall Out Boy&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 }
                </span>
                <span class="crayon-sy">
                 ,
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c8dd324701569-9">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Ben&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Kacey Musgraves&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 4
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Imagine Dragons&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 3
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c8dd324701569-10">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Lorde&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 3
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Fall Out Boy&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 }
                </span>
                <span class="crayon-sy">
                 ,
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c8dd324701569-11">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Chris&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Kacey Musgraves&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 4
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Imagine Dragons&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 4
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c8dd324701569-12">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Daft Punk&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 4
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Lorde&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 3
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Fall Out Boy&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 }
                </span>
                <span class="crayon-sy">
                 ,
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c8dd324701569-13">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Tori&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Kacey Musgraves&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 5
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Imagine Dragons&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 4
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c8dd324701569-14">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Daft Punk&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 5
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Fall Out Boy&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 3
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 }
                </span>
                <span class="crayon-sy">
                 }
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c8dd324701569-15">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c8dd324701569-16">
               </div>
               <div class="crayon-line" id="crayon-57685db75c8dd324701569-17">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-st"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 def
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-en"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 computeSimilarity
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-vpf"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 band1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-vpf"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 band2
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-vpf"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 userRatings
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c8dd324701569-18">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 averages
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-sy">
                 }
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c8dd324701569-19">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 for
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 key
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 ratings
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 in
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 userRatings
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 items
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c8dd324701569-20">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 averages
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 key
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s3"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-t">
                 float
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s3"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 sum
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 ratings
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 values
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s3"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 len
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 ratings
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 values
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c8dd324701569-21">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c8dd324701569-22">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 num
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 分子&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c8dd324701569-23">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 dem1
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 分母的第一部分&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c8dd324701569-24">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 dem2
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c8dd324701569-25">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 for
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 user
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 ratings
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 in
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 userRatings
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 items
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c8dd324701569-26">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 if
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 band1
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 in
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 ratings
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 and
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 band2
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 in
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 ratings
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c8dd324701569-27">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 avg
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 averages
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 user
                </span>
                <span class="crayon-sy">
                 ]
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c8dd324701569-28">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 num
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 +=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 ratings
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 band1
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 avg
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 *
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 ratings
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 band2
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 avg
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c8dd324701569-29">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 dem1
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 +=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 ratings
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 band1
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 avg
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 *
                </span>
                <span class="crayon-o">
                 *
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 2
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c8dd324701569-30">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 dem2
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 +=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 ratings
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 band2
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 avg
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 *
                </span>
                <span class="crayon-o">
                 *
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 2
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c8dd324701569-31">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 return
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 num
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-e">
                 sqrt
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 dem1
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 *
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 sqrt
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 dem2
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c8dd324701569-32">
               </div>
               <div class="crayon-line" id="crayon-57685db75c8dd324701569-33">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 print
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 computeSimilarity
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 '&lt;/span&gt;Kacey Musgraves&lt;span class="pl-pds"&gt;'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 '&lt;/span&gt;Lorde&lt;span class="pl-pds"&gt;'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 users3
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c8dd324701569-34">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 print
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 computeSimilarity
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 '&lt;/span&gt;Imagine Dragons&lt;span class="pl-pds"&gt;'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 '&lt;/span&gt;Lorde&lt;span class="pl-pds"&gt;'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 users3
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c8dd324701569-35">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 print
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 computeSimilarity
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 '&lt;/span&gt;Daft Punk&lt;span class="pl-pds"&gt;'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 '&lt;/span&gt;Lorde&lt;span class="pl-pds"&gt;'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 users3
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.2570 seconds] -->
       </div>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-22.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-22.png"/>
        </a>
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-23.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-23.png"/>
        </a>
       </p>
       <blockquote>
        <p>
         这个矩阵看起来不错，那下面该如何使用它来做预测呢？比如我想知道David有多喜欢Kacey Musgraves？
        </p>
       </blockquote>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-24.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-24.png"/>
        </a>
       </p>
       <p>
        p(u,i)表示我们会来预测用户u对物品i的评分，所以p(David, Kacey Musgraves)就表示我们将预测David会给Kacey打多少分。
       </p>
       <p>
        N是一个物品的集合，有如下特性：用户u对集合中的物品打过分；物品i和集合中的物品有相似度数据（即上文中的矩阵）。
       </p>
       <p>
        S
        <sub>
         i,N
        </sub>
        表示物品i和N的相似度，R
        <sub>
         u,N
        </sub>
        表示用户u对物品N的评分。
       </p>
       <p>
        为了让公式的计算效果更佳，对物品的评价分值最好介于-1和1之间。由于我们的评分系统是1至5星，所以需要使用一些运算将其转换到-1至1之间。
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-25.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-25.png"/>
        </a>
       </p>
       <p>
        我们的音乐评分系统是5分制，Max
        <sub>
         R
        </sub>
        表示评分系统中的最高分（这里是5），Min
        <sub>
         R
        </sub>
        为最低分（这里是1），R
        <sub>
         u,N
        </sub>
        是用户u对物品N的评分，NR
        <sub>
         u,N
        </sub>
        则表示修正后的评分（即范围在-1和1之间）。
       </p>
       <p>
        若已知NR
        <sub>
         u,N
        </sub>
        ，求解R
        <sub>
         u,N
        </sub>
        的公式为：
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-26.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-26.png"/>
        </a>
       </p>
       <p>
        比如一位用户给Fall Out Boy打了2分，那修正后的评分为：
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-27.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-27.png"/>
        </a>
       </p>
       <p>
        反过来则是：
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-28.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-28.png"/>
        </a>
       </p>
       <p>
        有了这个基础后，下面就让我们看看如何求解上文中的p(David, Kacey Musgraves)。
       </p>
       <p>
        首先我们要修正David对各个物品的评分：
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-29.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-29.png"/>
        </a>
       </p>
       <p>
        然后结合物品相似度矩阵，代入公式：
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-30.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-30.png"/>
        </a>
       </p>
       <p>
        所以，我们预测出David对Kacey Musgraves的评分是0.753，将其转换到5星评价体系中：
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-31.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-31.png"/>
        </a>
       </p>
       <p>
        最终的预测结果是4.506分。
       </p>
       <p>
        <strong>
         回顾
        </strong>
       </p>
       <ul class="task-list">
        <li>
         修正的余弦相似度是一种基于模型的协同过滤算法。我们前面提过，这种算法的优势之一是扩展性好，对于大数据量而言，运算速度快、占用内存少。
        </li>
        <li>
         用户的评价标准是不同的，比如喜欢一个歌手时有些人会打4分，有些打5分；不喜欢时有人会打3分，有些则会只给1分。修正的余弦相似度计算时会将用户对物品的评分减去用户所有评分的均值，从而解决这个问题。
        </li>
       </ul>
       <h2>
        <a class="anchor" href="https://github.com/jizhang/guidetodatamining/blob/master/chapter-3.md#slope-one%E7%AE%97%E6%B3%95" id="user-content-slope-one算法">
        </a>
        Slope One算法
       </h2>
       <p>
        还有一种比较流行的基于物品的协同过滤算法，名为Slope One，它最大的优势是简单，因此易于实现。Slope One算法是在一篇名为《
        <a href="http://www.daniel-lemire.com/fr/abstracts/SDM2005.html">
         Slope One：基于在线评分系统的协同过滤算法
        </a>
        》的论文中提出的，由Lemire和Machlachlan合著。这篇论文非常值得一读。
       </p>
       <p>
        我们用一个简单的例子来了解这个算法。假设Amy给PSY打了3分，Whitney Houston打了4分；Ben给PSY打了4分。我们要预测Ben会给Whitney Houston打几分。用表格来描述这个问题即：
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-32.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-32.png"/>
        </a>
       </p>
       <p>
        我们可以用以下逻辑来预测Ben对Whitney Houston的评分：由于Amy给Whitney Houston打的分数要比PSY的高一分，所以我们预测Ben也会给高一分，即给到5分。
       </p>
       <p>
        其实还有其他形式的Slope One算法，比如加权的Slope One。我们说过Slope One的优势之一是简单，下面说的加权的Slope One看起来会有一些复杂，但是只要耐心地看下去，事情就会变得很清晰了。
       </p>
       <p>
        你可以将Slope One分为两个步骤：首先需要计算出两两物品之间的差值（可以在夜间批量计算）。在上文的例子中，这个步骤就是得出Whitney Houston要比PSY高一分。第二步则是进行预测，比如一个新用户Ben来到了我们网站，他从未听过Whitney Houston的歌曲，我们想要预测他是否喜欢这位歌手。通过利用他评价过的歌手以及我们计算好的歌手之间的评分差值，就可以进行预测了。
       </p>
       <h3>
        <a class="anchor" href="https://github.com/jizhang/guidetodatamining/blob/master/chapter-3.md#%E7%AC%AC%E4%B8%80%E6%AD%A5%E8%AE%A1%E7%AE%97%E5%B7%AE%E5%80%BC" id="user-content-第一步计算差值">
        </a>
        第一步：计算差值
       </h3>
       <p>
        我们先为上述例子增加一些数据：
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-33.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-33.png"/>
        </a>
       </p>
       <p>
        计算物品之间差异的公式是：
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-34.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-34.png"/>
        </a>
       </p>
       <p>
        其中，card(S)表示S中有多少个元素；X表示所有评分值的集合；card(S
        <sub>
         j,i
        </sub>
        (X))则表示同时评价过物品j和i的用户数。我们来考察PSY和Taylor Swift之间的差值，card(S
        <sub>
         j,i
        </sub>
        (X))的值是2——因为有两个用户（Amy和Ben）同时对PSY和Taylor Swift打过分。分子u
        <sub>
         j
        </sub>
        -u
        <sub>
         i
        </sub>
        表示用户对j的评分减去对i的评分，代入公式得：
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-35.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-35.png"/>
        </a>
       </p>
       <p>
        所以PSY和Taylor Swift的差异是2，即用户们给Taylor Swift的评分比PSY要平均高出两分。那Taylor Swift和PSY的差异呢？
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-36.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-36.png"/>
        </a>
       </p>
       <p>
        <strong>
         作业：计算其他物品之间的差值
        </strong>
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-37.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-37.png"/>
        </a>
       </p>
       <p>
        <strong>
         头脑风暴
        </strong>
       </p>
       <p>
        试想我们的音乐站点有100万个用户对20万个歌手做评价。如果有一个新进的用户对10个歌手做了评价，我们是否需要重新计算20万×20万的差异数据，或是有其他更简单的方法？
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-38.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-38.png"/>
        </a>
       </p>
       <p>
        答案是你不需要计算整个数据集，这正是Slope One的美妙之处。对于两个物品，我们只需记录同时评价过这对物品的用户数就可以了。比如说Taylor Swift和PSY的差值是2，是根据9位用户的评价计算的。当有一个新用户对Taylor Swift打了5分，PSY打了1分时，更新后的差值为：
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-39.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-39.png"/>
        </a>
       </p>
       <h3>
        <a class="anchor" href="https://github.com/jizhang/guidetodatamining/blob/master/chapter-3.md#%E7%AC%AC%E4%BA%8C%E6%AD%A5%E4%BD%BF%E7%94%A8%E5%8A%A0%E6%9D%83%E7%9A%84slope-one%E7%AE%97%E6%B3%95%E8%BF%9B%E8%A1%8C%E9%A2%84%E6%B5%8B" id="user-content-第二步使用加权的slope-one算法进行预测">
        </a>
        第二步：使用加权的Slope One算法进行预测
       </h3>
       <p>
        好，现在我们有了物品之间的差异值，下面就用它来进行预测。这里我们将使用加权的Slope One算法来进行预测，用P
        <sup>
         WS1
        </sup>
        来表示，公式为：
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-40.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-40.png"/>
        </a>
       </p>
       <p>
        其中：
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-41.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-41.png"/>
        </a>
       </p>
       <p>
        P
        <sup>
         WS1
        </sup>
        (u)
        <sub>
         j
        </sub>
        表示我们将预测用户u对物品i的评分。比如P
        <sup>
         WS1
        </sup>
        (Ben)
        <sub>
         Whitney Houston
        </sub>
        表示Ben对Whitney Houston的预测评分。下面就让我们来求解这个问题。
       </p>
       <p>
        首先来看分子：
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-42.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-42.png"/>
        </a>
       </p>
       <p>
        表示遍历Ben评价过的所有歌手，除了Whitney Houston以外（也就是-{j}的意思）。
       </p>
       <p>
        整个分子的意思是：对于Ben评价过的所有歌手（Whitney Houston除外），找出Whitney Houston和这些歌手之间的差值，并将差值加上Ben对这个歌手的评分。同时，我们要将这个结果乘以同时评价过两位歌手的用户数。
       </p>
       <p>
        让我们分解开来看，先将Ben的评分情况和两两歌手之间的差异值展示如下：
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-43.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-43.png"/>
        </a>
       </p>
       <ol class="task-list">
        <li>
         Ben对Taylor Swift打了5分，也就是u
         <sub>
          i
         </sub>
        </li>
        <li>
         Whitney Houston和Taylor Swift的差异是-1，即dev
         <sub>
          j,i
         </sub>
        </li>
        <li>
         dev
         <sub>
          j,i
         </sub>
         + u
         <sub>
          i
         </sub>
         = 4
        </li>
        <li>
         共有两个用户（Amy和Daisy）同时对Taylor Swift和Whitney Houston做了评价，即c
         <sub>
          j,i
         </sub>
         = 2
        </li>
        <li>
         那么(dev
         <sub>
          j,i
         </sub>
         + u
         <sub>
          i
         </sub>
         ) c
         <sub>
          j,i
         </sub>
         = 4 × 2 = 8
        </li>
        <li>
         Ben对PSY打了2分
        </li>
        <li>
         Whitney Houston和PSY的差异是0.75
        </li>
        <li>
         dev
         <sub>
          j,i
         </sub>
         + u
         <sub>
          i
         </sub>
         = 2.75
        </li>
        <li>
         有两个用户同时评价了这两位歌手，因此(dev
         <sub>
          j,i
         </sub>
         + u
         <sub>
          i
         </sub>
         ) c
         <sub>
          j,i
         </sub>
         = 2.75 × 2 = 5.5
        </li>
        <li>
         分子：8 + 5.5 = 13.5
        </li>
        <li>
         分母：2 + 2 = 4
        </li>
        <li>
         预测评分：13.5 ÷ 4 = 3.375
        </li>
       </ol>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-44.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-44.png"/>
        </a>
       </p>
       <h2>
        <a class="anchor" href="https://github.com/jizhang/guidetodatamining/blob/master/chapter-3.md#%E4%BD%BF%E7%94%A8python%E5%AE%9E%E7%8E%B0slope-one%E7%AE%97%E6%B3%95" id="user-content-使用python实现slope-one算法">
        </a>
        使用Python实现Slope One算法
       </h2>
       <p>
        我们将沿用第二章中编写的Python类，重复的代码我不在这里赘述。输入的数据是这样的：
       </p>
       <div class="highlight highlight-python">
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685db75c903957969146" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           users2 &lt;span class="pl-k"&gt;=&lt;/span&gt; {&lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Amy&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: {&lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Taylor Swift&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;4&lt;/span&gt;, &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;PSY&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;3&lt;/span&gt;, &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Whitney Houston&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;4&lt;/span&gt;},
          &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Ben&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: {&lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Taylor Swift&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;5&lt;/span&gt;, &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;PSY&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;2&lt;/span&gt;},
          &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Clara&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: {&lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;PSY&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;3.5&lt;/span&gt;, &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Whitney Houston&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;4&lt;/span&gt;},
          &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Daisy&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: {&lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Taylor Swift&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;5&lt;/span&gt;, &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;Whitney Houston&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;3&lt;/span&gt;}}
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685db75c903957969146-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c903957969146-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c903957969146-3">
                3
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c903957969146-4">
                4
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685db75c903957969146-1">
                <span class="crayon-v">
                 users2
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Amy&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Taylor Swift&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 4
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;PSY&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 3
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Whitney Houston&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 4
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 }
                </span>
                <span class="crayon-sy">
                 ,
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c903957969146-2">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Ben&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Taylor Swift&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 5
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;PSY&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 2
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 }
                </span>
                <span class="crayon-sy">
                 ,
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c903957969146-3">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Clara&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;PSY&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 3.5
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Whitney Houston&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 4
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 }
                </span>
                <span class="crayon-sy">
                 ,
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c903957969146-4">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Daisy&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Taylor Swift&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 5
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 "&lt;/span&gt;Whitney Houston&lt;span class="
                </span>
                <span class="crayon-v">
                 pl
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-i">
                 pds
                </span>
                <span class="crayon-s">
                 "&gt;"
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 3
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 }
                </span>
                <span class="crayon-sy">
                 }
                </span>
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.0601 seconds] -->
       </div>
       <p>
        我们先来计算两两物品之间的差异，公式是：
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-45.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-45.png"/>
        </a>
       </p>
       <p>
        计算后的输出结果应该如下表所示：
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-46.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-46.png"/>
        </a>
       </p>
       <p>
        括号中的数值表示同时给这两个歌手评过分的用户数。
       </p>
       <h3>
        <a class="anchor" href="https://github.com/jizhang/guidetodatamining/blob/master/chapter-3.md#%E7%AC%AC%E4%B8%80%E6%AD%A5" id="user-content-第一步">
        </a>
        第一步
       </h3>
       <div class="highlight highlight-python">
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685db75c910609122676" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           &lt;span class="pl-st"&gt;def&lt;/span&gt; &lt;span class="pl-en"&gt;computeDeviations&lt;/span&gt;(&lt;span class="pl-vpf"&gt;self&lt;/span&gt;):
    &lt;span class="pl-c"&gt;# 获取每位用户的评分数据&lt;/span&gt;
    &lt;span class="pl-k"&gt;for&lt;/span&gt; ratings &lt;span class="pl-k"&gt;in&lt;/span&gt; &lt;span class="pl-v"&gt;self&lt;/span&gt;.data.values():
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685db75c910609122676-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c910609122676-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c910609122676-3">
                3
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685db75c910609122676-1">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-st"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 def
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-en"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 computeDeviations
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-vpf"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c910609122676-2">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 获取每位用户的评分数据&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c910609122676-3">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 for
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 ratings
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 in
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-v"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 data
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 values
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.0061 seconds] -->
       </div>
       <p>
        self.data是一个Python字典，它的values()方法可以获取所有键的值。比如上述代码在第一次迭代时，ratings变量的值为{“Taylor Swift”: 4, “PSY”: 3, “Whitney Houston”: 4}。
       </p>
       <h3>
        <a class="anchor" href="https://github.com/jizhang/guidetodatamining/blob/master/chapter-3.md#%E7%AC%AC%E4%BA%8C%E6%AD%A5" id="user-content-第二步">
        </a>
        第二步
       </h3>
       <div class="highlight highlight-python">
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685db75c917998631394" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           &lt;span class="pl-st"&gt;def&lt;/span&gt; &lt;span class="pl-en"&gt;computeDeviations&lt;/span&gt;(&lt;span class="pl-vpf"&gt;self&lt;/span&gt;):
    &lt;span class="pl-c"&gt;# 获取每位用户的评分数据&lt;/span&gt;
    &lt;span class="pl-k"&gt;for&lt;/span&gt; ratings &lt;span class="pl-k"&gt;in&lt;/span&gt; &lt;span class="pl-v"&gt;self&lt;/span&gt;.data.values():
        &lt;span class="pl-c"&gt;# 对于该用户的每个评分项（歌手、分数）&lt;/span&gt;
        &lt;span class="pl-k"&gt;for&lt;/span&gt; (item, rating) &lt;span class="pl-k"&gt;in&lt;/span&gt; ratings.items():
            &lt;span class="pl-v"&gt;self&lt;/span&gt;.frequencies.setdefault(item, {})
            &lt;span class="pl-v"&gt;self&lt;/span&gt;.deviations.setdefault(item, {})
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685db75c917998631394-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c917998631394-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c917998631394-3">
                3
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c917998631394-4">
                4
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c917998631394-5">
                5
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c917998631394-6">
                6
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c917998631394-7">
                7
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685db75c917998631394-1">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-st"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 def
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-en"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 computeDeviations
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-vpf"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c917998631394-2">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 获取每位用户的评分数据&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c917998631394-3">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 for
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 ratings
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 in
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-v"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 data
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 values
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c917998631394-4">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 对于该用户的每个评分项（歌手、分数）&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c917998631394-5">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 for
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 item
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 rating
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 in
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 ratings
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 items
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c917998631394-6">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-v"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 frequencies
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 setdefault
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 item
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-sy">
                 }
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c917998631394-7">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-v"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 deviations
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 setdefault
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 item
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-sy">
                 }
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.0255 seconds] -->
       </div>
       <p>
        在这个类的初始化方法中，我们需要对self.frequencies和self.deviations进行赋值：
       </p>
       <div class="highlight highlight-python">
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685db75c91d146137978" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           &lt;span class="pl-st"&gt;def&lt;/span&gt; &lt;span class="pl-en"&gt;&lt;span class="pl-s3"&gt;__init__&lt;/span&gt;&lt;/span&gt;(&lt;span class="pl-vpf"&gt;self&lt;/span&gt;, &lt;span class="pl-vpf"&gt;data&lt;/span&gt;, &lt;span class="pl-vpf"&gt;k&lt;/span&gt;&lt;span class="pl-k"&gt;=&lt;/span&gt;&lt;span class="pl-c1"&gt;1&lt;/span&gt;, &lt;span class="pl-vpf"&gt;metric&lt;/span&gt;&lt;span class="pl-k"&gt;=&lt;/span&gt;&lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;'&lt;/span&gt;pearson&lt;span class="pl-pds"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="pl-vpf"&gt;n&lt;/span&gt;&lt;span class="pl-k"&gt;=&lt;/span&gt;&lt;span class="pl-c1"&gt;5&lt;/span&gt;):
    ...
    &lt;span class="pl-c"&gt;# 以下变量将用于Slope One算法&lt;/span&gt;
    &lt;span class="pl-v"&gt;self&lt;/span&gt;.frequencies &lt;span class="pl-k"&gt;=&lt;/span&gt; {}
    &lt;span class="pl-v"&gt;self&lt;/span&gt;.deviations &lt;span class="pl-k"&gt;=&lt;/span&gt; {}
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685db75c91d146137978-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c91d146137978-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c91d146137978-3">
                3
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c91d146137978-4">
                4
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c91d146137978-5">
                5
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685db75c91d146137978-1">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-st"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 def
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-en"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s3"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 __init__
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-vpf"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-vpf"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 data
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-vpf"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 k
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-vpf"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 metric
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 '&lt;/span&gt;pearson&lt;span class="pl-pds"&gt;'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-vpf"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 n
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 5
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c91d146137978-2">
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-sy">
                 .
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c91d146137978-3">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 以下变量将用于Slope One算法&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c91d146137978-4">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-v"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 frequencies
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-sy">
                 }
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c91d146137978-5">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-v"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 deviations
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-sy">
                 }
                </span>
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.0302 seconds] -->
       </div>
       <p>
        Python字典的setdefault()方法接受两个参数，它的作用是：如果字典中不包含指定的键，则将其设为默认值；若存在，则返回其对应的值。
       </p>
       <h3>
        <a class="anchor" href="https://github.com/jizhang/guidetodatamining/blob/master/chapter-3.md#%E7%AC%AC%E4%B8%89%E6%AD%A5" id="user-content-第三步">
        </a>
        第三步
       </h3>
       <div class="highlight highlight-python">
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685db75c924670529982" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           &lt;span class="pl-st"&gt;def&lt;/span&gt; &lt;span class="pl-en"&gt;computeDeviations&lt;/span&gt;(&lt;span class="pl-vpf"&gt;self&lt;/span&gt;):
    &lt;span class="pl-c"&gt;# 获取每位用户的评分数据&lt;/span&gt;
    &lt;span class="pl-k"&gt;for&lt;/span&gt; ratings &lt;span class="pl-k"&gt;in&lt;/span&gt; &lt;span class="pl-v"&gt;self&lt;/span&gt;.data.values():
        &lt;span class="pl-c"&gt;# 对于该用户的每个评分项（歌手、分数）&lt;/span&gt;
        &lt;span class="pl-k"&gt;for&lt;/span&gt; (item, rating) &lt;span class="pl-k"&gt;in&lt;/span&gt; ratings.items():
            &lt;span class="pl-v"&gt;self&lt;/span&gt;.frequencies.setdefault(item, {})
            &lt;span class="pl-v"&gt;self&lt;/span&gt;.deviations.setdefault(item, {})
            &lt;span class="pl-c"&gt;# 再次遍历该用户的每个评分项&lt;/span&gt;
            &lt;span class="pl-k"&gt;for&lt;/span&gt; (item2, rating2) &lt;span class="pl-k"&gt;in&lt;/span&gt; ratings.items():
                &lt;span class="pl-k"&gt;if&lt;/span&gt; item &lt;span class="pl-k"&gt;!=&lt;/span&gt; item2:
                    &lt;span class="pl-c"&gt;# 将评分的差异保存到变量中&lt;/span&gt;
                    &lt;span class="pl-v"&gt;self&lt;/span&gt;.frequencies[item].setdefault(item2, &lt;span class="pl-c1"&gt;0&lt;/span&gt;)
                    &lt;span class="pl-v"&gt;self&lt;/span&gt;.deviations[item].setdefault(item2, &lt;span class="pl-c1"&gt;0.0&lt;/span&gt;)
                    &lt;span class="pl-v"&gt;self&lt;/span&gt;.frequencies[item][item2] &lt;span class="pl-k"&gt;+=&lt;/span&gt; &lt;span class="pl-c1"&gt;1&lt;/span&gt;
                    &lt;span class="pl-v"&gt;self&lt;/span&gt;.deviations[item][item2] &lt;span class="pl-k"&gt;+=&lt;/span&gt; rating &lt;span class="pl-k"&gt;-&lt;/span&gt; rating2
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685db75c924670529982-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c924670529982-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c924670529982-3">
                3
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c924670529982-4">
                4
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c924670529982-5">
                5
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c924670529982-6">
                6
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c924670529982-7">
                7
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c924670529982-8">
                8
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c924670529982-9">
                9
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c924670529982-10">
                10
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c924670529982-11">
                11
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c924670529982-12">
                12
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c924670529982-13">
                13
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c924670529982-14">
                14
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c924670529982-15">
                15
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685db75c924670529982-1">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-st"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 def
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-en"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 computeDeviations
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-vpf"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c924670529982-2">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 获取每位用户的评分数据&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c924670529982-3">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 for
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 ratings
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 in
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-v"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 data
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 values
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c924670529982-4">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 对于该用户的每个评分项（歌手、分数）&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c924670529982-5">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 for
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 item
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 rating
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 in
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 ratings
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 items
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c924670529982-6">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-v"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 frequencies
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 setdefault
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 item
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-sy">
                 }
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c924670529982-7">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-v"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 deviations
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 setdefault
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 item
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-sy">
                 }
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c924670529982-8">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 再次遍历该用户的每个评分项&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c924670529982-9">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 for
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 item2
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 rating2
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 in
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 ratings
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 items
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c924670529982-10">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 if
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 item
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 !=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 item2
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c924670529982-11">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 将评分的差异保存到变量中&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c924670529982-12">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-v"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 frequencies
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 item
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 setdefault
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 item2
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c924670529982-13">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-v"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 deviations
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 item
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 setdefault
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 item2
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0.0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c924670529982-14">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-v"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 frequencies
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 item
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 item2
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 +=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c924670529982-15">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-v"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 deviations
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 item
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 item2
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 +=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 rating
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 rating2
                </span>
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.0605 seconds] -->
       </div>
       <p>
        还是用{“Taylor Swift”: 4, “PSY”: 3, “Whitney Houston”: 4}举例，在第一次遍历中，外层循环item = “Taylor Swift”，rating = 4；内层循环item2 = “PSY”，rating2 = 3，因此最后一行代码是对self.deviations[“Taylor Swift”][“PSY”]做+1的操作。
       </p>
       <h3>
        <a class="anchor" href="https://github.com/jizhang/guidetodatamining/blob/master/chapter-3.md#%E7%AC%AC%E5%9B%9B%E6%AD%A5" id="user-content-第四步">
        </a>
        第四步
       </h3>
       <p>
        最后，我们便可计算出差异值：
       </p>
       <div class="highlight highlight-python">
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685db75c92d600065036" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           &lt;span class="pl-st"&gt;def&lt;/span&gt; &lt;span class="pl-en"&gt;computeDeviations&lt;/span&gt;(&lt;span class="pl-vpf"&gt;self&lt;/span&gt;):
    &lt;span class="pl-c"&gt;# 获取每位用户的评分数据&lt;/span&gt;
    &lt;span class="pl-k"&gt;for&lt;/span&gt; ratings &lt;span class="pl-k"&gt;in&lt;/span&gt; &lt;span class="pl-v"&gt;self&lt;/span&gt;.data.values():
        &lt;span class="pl-c"&gt;# 对于该用户的每个评分项（歌手、分数）&lt;/span&gt;
        &lt;span class="pl-k"&gt;for&lt;/span&gt; (item, rating) &lt;span class="pl-k"&gt;in&lt;/span&gt; ratings.items():
            &lt;span class="pl-v"&gt;self&lt;/span&gt;.frequencies.setdefault(item, {})
            &lt;span class="pl-v"&gt;self&lt;/span&gt;.deviations.setdefault(item, {})
            &lt;span class="pl-c"&gt;# 再次遍历该用户的每个评分项&lt;/span&gt;
            &lt;span class="pl-k"&gt;for&lt;/span&gt; (item2, rating2) &lt;span class="pl-k"&gt;in&lt;/span&gt; ratings.items():
                &lt;span class="pl-k"&gt;if&lt;/span&gt; item &lt;span class="pl-k"&gt;!=&lt;/span&gt; item2:
                    &lt;span class="pl-c"&gt;# 将评分的差异保存到变量中&lt;/span&gt;
                    &lt;span class="pl-v"&gt;self&lt;/span&gt;.frequencies[item].setdefault(item2, &lt;span class="pl-c1"&gt;0&lt;/span&gt;)
                    &lt;span class="pl-v"&gt;self&lt;/span&gt;.deviations[item].setdefault(item2, &lt;span class="pl-c1"&gt;0.0&lt;/span&gt;)
                    &lt;span class="pl-v"&gt;self&lt;/span&gt;.frequencies[item][item2] &lt;span class="pl-k"&gt;+=&lt;/span&gt; &lt;span class="pl-c1"&gt;1&lt;/span&gt;
                    &lt;span class="pl-v"&gt;self&lt;/span&gt;.deviations[item][item2] &lt;span class="pl-k"&gt;+=&lt;/span&gt; rating &lt;span class="pl-k"&gt;-&lt;/span&gt; rating2

    &lt;span class="pl-k"&gt;for&lt;/span&gt; (item, ratings) &lt;span class="pl-k"&gt;in&lt;/span&gt; &lt;span class="pl-v"&gt;self&lt;/span&gt;.deviations.items():
        &lt;span class="pl-k"&gt;for&lt;/span&gt; item2 &lt;span class="pl-k"&gt;in&lt;/span&gt; ratings:
            ratings[item2] &lt;span class="pl-k"&gt;/=&lt;/span&gt; &lt;span class="pl-v"&gt;self&lt;/span&gt;.frequencies[item][item2]
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685db75c92d600065036-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c92d600065036-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c92d600065036-3">
                3
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c92d600065036-4">
                4
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c92d600065036-5">
                5
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c92d600065036-6">
                6
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c92d600065036-7">
                7
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c92d600065036-8">
                8
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c92d600065036-9">
                9
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c92d600065036-10">
                10
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c92d600065036-11">
                11
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c92d600065036-12">
                12
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c92d600065036-13">
                13
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c92d600065036-14">
                14
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c92d600065036-15">
                15
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c92d600065036-16">
                16
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c92d600065036-17">
                17
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c92d600065036-18">
                18
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c92d600065036-19">
                19
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685db75c92d600065036-1">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-st"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 def
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-en"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 computeDeviations
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-vpf"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c92d600065036-2">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 获取每位用户的评分数据&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c92d600065036-3">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 for
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 ratings
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 in
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-v"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 data
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 values
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c92d600065036-4">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 对于该用户的每个评分项（歌手、分数）&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c92d600065036-5">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 for
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 item
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 rating
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 in
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 ratings
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 items
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c92d600065036-6">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-v"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 frequencies
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 setdefault
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 item
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-sy">
                 }
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c92d600065036-7">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-v"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 deviations
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 setdefault
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 item
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-sy">
                 }
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c92d600065036-8">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 再次遍历该用户的每个评分项&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c92d600065036-9">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 for
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 item2
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 rating2
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 in
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 ratings
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 items
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c92d600065036-10">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 if
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 item
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 !=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 item2
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c92d600065036-11">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 将评分的差异保存到变量中&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c92d600065036-12">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-v"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 frequencies
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 item
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 setdefault
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 item2
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c92d600065036-13">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-v"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 deviations
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 item
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 setdefault
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 item2
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0.0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c92d600065036-14">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-v"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 frequencies
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 item
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 item2
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 +=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c92d600065036-15">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-v"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 deviations
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 item
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 item2
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 +=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 rating
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 rating2
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c92d600065036-16">
               </div>
               <div class="crayon-line" id="crayon-57685db75c92d600065036-17">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 for
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 item
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 ratings
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 in
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-v"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 deviations
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 items
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c92d600065036-18">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 for
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 item2
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 in
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 ratings
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c92d600065036-19">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 ratings
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 item2
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 /=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-v"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 frequencies
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 item
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 item2
                </span>
                <span class="crayon-sy">
                 ]
                </span>
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.0671 seconds] -->
       </div>
       <p>
        完成了！仅仅用了18代码我们就实现了这个公式：
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-45.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-45.png"/>
        </a>
       </p>
       <p>
        让我们测试一下：
       </p>
       <div class="highlight highlight-python">
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685db75c936831882226" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           &lt;span class="pl-k"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; r &lt;span class="pl-k"&gt;=&lt;/span&gt; Recommender()
&lt;span class="pl-k"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; r.computeDeviations()
&lt;span class="pl-k"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; r.deviations
{&lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;'&lt;/span&gt;PSY&lt;span class="pl-pds"&gt;'&lt;/span&gt;&lt;/span&gt;: {&lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;'&lt;/span&gt;Taylor Swift&lt;span class="pl-pds"&gt;'&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-k"&gt;-&lt;/span&gt;&lt;span class="pl-c1"&gt;2.0&lt;/span&gt;, &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;'&lt;/span&gt;Whitney Houston&lt;span class="pl-pds"&gt;'&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-k"&gt;-&lt;/span&gt;&lt;span class="pl-c1"&gt;0.75&lt;/span&gt;}, &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;'&lt;/span&gt;Taylor Swift&lt;span class="pl-pds"&gt;'&lt;/span&gt;&lt;/span&gt;: {&lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;'&lt;/span&gt;PSY&lt;span class="pl-pds"&gt;'&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;2.0&lt;/span&gt;, &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;'&lt;/span&gt;Whitney Houston&lt;span class="pl-pds"&gt;'&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;1.0&lt;/span&gt;}, &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;'&lt;/span&gt;Whitney Houston&lt;span class="pl-pds"&gt;'&lt;/span&gt;&lt;/span&gt;: {&lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;'&lt;/span&gt;PSY&lt;span class="pl-pds"&gt;'&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-c1"&gt;0.75&lt;/span&gt;, &lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;'&lt;/span&gt;Taylor Swift&lt;span class="pl-pds"&gt;'&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-k"&gt;-&lt;/span&gt;&lt;span class="pl-c1"&gt;1.0&lt;/span&gt;}}
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685db75c936831882226-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c936831882226-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c936831882226-3">
                3
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c936831882226-4">
                4
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685db75c936831882226-1">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &amp;
                </span>
                <span class="crayon-v">
                 gt
                </span>
                <span class="crayon-sy">
                 ;
                </span>
                <span class="crayon-o">
                 &amp;
                </span>
                <span class="crayon-v">
                 gt
                </span>
                <span class="crayon-sy">
                 ;
                </span>
                <span class="crayon-o">
                 &amp;
                </span>
                <span class="crayon-v">
                 gt
                </span>
                <span class="crayon-sy">
                 ;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 r
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 Recommender
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c936831882226-2">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &amp;
                </span>
                <span class="crayon-v">
                 gt
                </span>
                <span class="crayon-sy">
                 ;
                </span>
                <span class="crayon-o">
                 &amp;
                </span>
                <span class="crayon-v">
                 gt
                </span>
                <span class="crayon-sy">
                 ;
                </span>
                <span class="crayon-o">
                 &amp;
                </span>
                <span class="crayon-v">
                 gt
                </span>
                <span class="crayon-sy">
                 ;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 r
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 computeDeviations
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c936831882226-3">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &amp;
                </span>
                <span class="crayon-v">
                 gt
                </span>
                <span class="crayon-sy">
                 ;
                </span>
                <span class="crayon-o">
                 &amp;
                </span>
                <span class="crayon-v">
                 gt
                </span>
                <span class="crayon-sy">
                 ;
                </span>
                <span class="crayon-o">
                 &amp;
                </span>
                <span class="crayon-v">
                 gt
                </span>
                <span class="crayon-sy">
                 ;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 r
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-i">
                 deviations
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c936831882226-4">
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 '&lt;/span&gt;PSY&lt;span class="pl-pds"&gt;'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 '&lt;/span&gt;Taylor Swift&lt;span class="pl-pds"&gt;'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 2.0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 '&lt;/span&gt;Whitney Houston&lt;span class="pl-pds"&gt;'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0.75
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 }
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 '&lt;/span&gt;Taylor Swift&lt;span class="pl-pds"&gt;'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 '&lt;/span&gt;PSY&lt;span class="pl-pds"&gt;'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 2.0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 '&lt;/span&gt;Whitney Houston&lt;span class="pl-pds"&gt;'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1.0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 }
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 '&lt;/span&gt;Whitney Houston&lt;span class="pl-pds"&gt;'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 '&lt;/span&gt;PSY&lt;span class="pl-pds"&gt;'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0.75
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 '&lt;/span&gt;Taylor Swift&lt;span class="pl-pds"&gt;'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 -
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1.0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 }
                </span>
                <span class="crayon-sy">
                 }
                </span>
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.0543 seconds] -->
       </div>
       <p>
        结果和我们之前手工计算的一致：
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-47.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-47.png"/>
        </a>
       </p>
       <p>
        <strong>
         感谢
         <a href="http://www.serpentine.com/blog/">
          Bryan O’Sullivan
         </a>
         ，这里用Python实现的Slope One算法正是基于他的成果。
        </strong>
       </p>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-48.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-48.png"/>
        </a>
       </p>
       <h3>
        <a class="anchor" href="https://github.com/jizhang/guidetodatamining/blob/master/chapter-3.md#%E5%8A%A0%E6%9D%83%E7%9A%84slope-one%E7%AE%97%E6%B3%95%E6%8E%A8%E8%8D%90%E9%80%BB%E8%BE%91%E7%9A%84%E5%AE%9E%E7%8E%B0" id="user-content-加权的slope-one算法推荐逻辑的实现">
        </a>
        加权的Slope One算法：推荐逻辑的实现
       </h3>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-49.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-49.png"/>
        </a>
       </p>
       <div class="highlight highlight-python">
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685db75c93f838218837" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           &lt;span class="pl-st"&gt;def&lt;/span&gt; &lt;span class="pl-en"&gt;slopeOneRecommendations&lt;/span&gt;(&lt;span class="pl-vpf"&gt;self&lt;/span&gt;, &lt;span class="pl-vpf"&gt;userRatings&lt;/span&gt;):
    recommendations &lt;span class="pl-k"&gt;=&lt;/span&gt; {}
    frequencies &lt;span class="pl-k"&gt;=&lt;/span&gt; {}
    &lt;span class="pl-c"&gt;# 遍历目标用户的评分项（歌手、分数）&lt;/span&gt;
    &lt;span class="pl-k"&gt;for&lt;/span&gt; (userItem, userRating) &lt;span class="pl-k"&gt;in&lt;/span&gt; userRatings.items():
        &lt;span class="pl-c"&gt;# 对目标用户未评价的歌手进行计算&lt;/span&gt;
        &lt;span class="pl-k"&gt;for&lt;/span&gt; (diffItem, diffRatings) &lt;span class="pl-k"&gt;in&lt;/span&gt; &lt;span class="pl-v"&gt;self&lt;/span&gt;.deviations.items():
            &lt;span class="pl-k"&gt;if&lt;/span&gt; diffItem &lt;span class="pl-k"&gt;not&lt;/span&gt; &lt;span class="pl-k"&gt;in&lt;/span&gt; userRatings &lt;span class="pl-k"&gt;and&lt;/span&gt; userItem &lt;span class="pl-k"&gt;in&lt;/span&gt; &lt;span class="pl-v"&gt;self&lt;/span&gt;.deviations[diffItem]:
                freq &lt;span class="pl-k"&gt;=&lt;/span&gt; &lt;span class="pl-v"&gt;self&lt;/span&gt;.frequencies[diffItem][userItem]
                recommendations.setdefault(diffItem, &lt;span class="pl-c1"&gt;0.0&lt;/span&gt;)
                frequencies.setdefault(diffItem, &lt;span class="pl-c1"&gt;0&lt;/span&gt;)
                &lt;span class="pl-c"&gt;# 分子&lt;/span&gt;
                recommendations[diffItem] &lt;span class="pl-k"&gt;+=&lt;/span&gt; (diffRatings[userItem] &lt;span class="pl-k"&gt;+&lt;/span&gt; userRating) &lt;span class="pl-k"&gt;*&lt;/span&gt; freq
                &lt;span class="pl-c"&gt;# 分母&lt;/span&gt;
                frequencies[diffItem] &lt;span class="pl-k"&gt;+=&lt;/span&gt; freq

    recommendations &lt;span class="pl-k"&gt;=&lt;/span&gt; [(k, v &lt;span class="pl-k"&gt;/&lt;/span&gt; frequencies[k]) &lt;span class="pl-k"&gt;for&lt;/span&gt; (k, v) &lt;span class="pl-k"&gt;in&lt;/span&gt; recommendations.items()]
    &lt;span class="pl-c"&gt;# 排序并返回&lt;/span&gt;
    recommendations.sort(&lt;span class="pl-vpf"&gt;key&lt;/span&gt;&lt;span class="pl-k"&gt;=&lt;/span&gt;&lt;span class="pl-st"&gt;lambda&lt;/span&gt; &lt;span class="pl-vpf"&gt;artistTuple&lt;/span&gt;: artistTuple[&lt;span class="pl-c1"&gt;1&lt;/span&gt;], &lt;span class="pl-vpf"&gt;reverse&lt;/span&gt;&lt;span class="pl-k"&gt;=&lt;/span&gt;&lt;span class="pl-c1"&gt;True&lt;/span&gt;)
    &lt;span class="pl-k"&gt;return&lt;/span&gt; recommendations

&lt;span class="pl-k"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; r.slopeOneRecommendations(users2[&lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;'&lt;/span&gt;Ben&lt;span class="pl-pds"&gt;'&lt;/span&gt;&lt;/span&gt;])
[(&lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;'&lt;/span&gt;Whitney Houston&lt;span class="pl-pds"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="pl-c1"&gt;3.375&lt;/span&gt;)]
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685db75c93f838218837-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c93f838218837-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c93f838218837-3">
                3
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c93f838218837-4">
                4
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c93f838218837-5">
                5
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c93f838218837-6">
                6
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c93f838218837-7">
                7
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c93f838218837-8">
                8
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c93f838218837-9">
                9
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c93f838218837-10">
                10
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c93f838218837-11">
                11
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c93f838218837-12">
                12
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c93f838218837-13">
                13
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c93f838218837-14">
                14
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c93f838218837-15">
                15
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c93f838218837-16">
                16
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c93f838218837-17">
                17
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c93f838218837-18">
                18
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c93f838218837-19">
                19
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c93f838218837-20">
                20
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c93f838218837-21">
                21
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c93f838218837-22">
                22
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c93f838218837-23">
                23
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685db75c93f838218837-1">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-st"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 def
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-en"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 slopeOneRecommendations
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-vpf"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-vpf"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 userRatings
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c93f838218837-2">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 recommendations
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-sy">
                 }
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c93f838218837-3">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 frequencies
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 {
                </span>
                <span class="crayon-sy">
                 }
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c93f838218837-4">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 遍历目标用户的评分项（歌手、分数）&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c93f838218837-5">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 for
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 userItem
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 userRating
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 in
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 userRatings
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 items
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c93f838218837-6">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 对目标用户未评价的歌手进行计算&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c93f838218837-7">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 for
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 diffItem
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 diffRatings
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 in
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-v"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 deviations
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 items
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c93f838218837-8">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 if
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 diffItem
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 not
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 in
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 userRatings
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 and
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 userItem
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 in
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-v"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 deviations
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 diffItem
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-o">
                 :
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c93f838218837-9">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 freq
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-v"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-r">
                 self
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 frequencies
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 diffItem
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 userItem
                </span>
                <span class="crayon-sy">
                 ]
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c93f838218837-10">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 recommendations
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 setdefault
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 diffItem
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0.0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c93f838218837-11">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 frequencies
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 setdefault
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 diffItem
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c93f838218837-12">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 分子&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c93f838218837-13">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 recommendations
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 diffItem
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 +=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 diffRatings
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 userItem
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 +
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 userRating
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 *
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 freq
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c93f838218837-14">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 分母&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c93f838218837-15">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 frequencies
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 diffItem
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 +=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 freq
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c93f838218837-16">
               </div>
               <div class="crayon-line" id="crayon-57685db75c93f838218837-17">
                <span class="crayon-e">
                </span>
                <span class="crayon-v">
                 recommendations
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 k
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 v
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 frequencies
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-v">
                 k
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 for
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 k
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 v
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 in
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 recommendations
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 items
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 ]
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c93f838218837-18">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 排序并返回&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c93f838218837-19">
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 recommendations
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 sort
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-vpf"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 key
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-st"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 lambda
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-vpf"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 artistTuple
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 :
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 artistTuple
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 1
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-vpf"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-v">
                 reverse
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-t">
                 True
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c93f838218837-20">
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-st">
                 return
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 recommendations
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c93f838218837-21">
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c93f838218837-22">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &amp;
                </span>
                <span class="crayon-v">
                 gt
                </span>
                <span class="crayon-sy">
                 ;
                </span>
                <span class="crayon-o">
                 &amp;
                </span>
                <span class="crayon-v">
                 gt
                </span>
                <span class="crayon-sy">
                 ;
                </span>
                <span class="crayon-o">
                 &amp;
                </span>
                <span class="crayon-v">
                 gt
                </span>
                <span class="crayon-sy">
                 ;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 r
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 slopeOneRecommendations
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 users2
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 '&lt;/span&gt;Ben&lt;span class="pl-pds"&gt;'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c93f838218837-23">
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 '&lt;/span&gt;Whitney Houston&lt;span class="pl-pds"&gt;'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 3.375
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 ]
                </span>
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.0999 seconds] -->
       </div>
       <h3>
        <a class="anchor" href="https://github.com/jizhang/guidetodatamining/blob/master/chapter-3.md#movielens%E6%95%B0%E6%8D%AE%E9%9B%86" id="user-content-movielens数据集">
        </a>
        MovieLens数据集
       </h3>
       <p>
        让我们在另一个数据集上尝试一下Slope One算法。MovieLens数据集是由明尼苏达州大学的GroupLens研究项目收集的，是用户对电影的评分。这个数据集可以在
        <a href="http://www.grouplens.org/">
         www.grouplens.org
        </a>
        下载，有三种大小，这里我使用的是最小的那个，包含了943位用户对1682部电影的评价，约10万条记录。我们一起来测试一下：
       </p>
       <div class="highlight highlight-python">
        <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
        <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57685db75c949771156733" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
         <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <span class="crayon-title">
          </span>
          <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-wrap-button" title="切换自动换行">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-expand-button" title="点击展开代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-copy-button" title="复制代码">
            <div class="crayon-button-icon">
            </div>
           </div>
           <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
            <div class="crayon-button-icon">
            </div>
           </div>
          </div>
         </div>
         <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
         </div>
         <div class="crayon-plain-wrap">
          <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           &lt;span class="pl-k"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; r &lt;span class="pl-k"&gt;=&lt;/span&gt; recommender(&lt;span class="pl-c1"&gt;0&lt;/span&gt;)
&lt;span class="pl-k"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; r.loadMovieLens(&lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;'&lt;/span&gt;/Users/raz/Downloads/ml-100k/&lt;span class="pl-pds"&gt;'&lt;/span&gt;&lt;/span&gt;)
&lt;span class="pl-c1"&gt;102625&lt;/span&gt;
&lt;span class="pl-k"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; r.computeDeviations() &lt;span class="pl-c"&gt;# 大约需要50秒&lt;/span&gt;
&lt;span class="pl-k"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; r.slopeOneRecommendations(r.data[&lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;'&lt;/span&gt;25&lt;span class="pl-pds"&gt;'&lt;/span&gt;&lt;/span&gt;])
[(&lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;'&lt;/span&gt;Aiqing wansui (1994)&lt;span class="pl-pds"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="pl-c1"&gt;5.674418604651163&lt;/span&gt;), (&lt;span class="pl-s1"&gt;&lt;span class="pl-pds"&gt;'&lt;/span&gt;Boys, Les (1997)&lt;span class="pl-pds"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="pl-c1"&gt;5.523076923076923&lt;/span&gt;), ...]
          </textarea>
         </div>
         <div class="crayon-main" style="">
          <table class="crayon-table">
           <tbody>
            <tr class="crayon-row">
             <td class="crayon-nums " data-settings="show">
              <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
               <div class="crayon-num" data-line="crayon-57685db75c949771156733-1">
                1
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c949771156733-2">
                2
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c949771156733-3">
                3
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c949771156733-4">
                4
               </div>
               <div class="crayon-num" data-line="crayon-57685db75c949771156733-5">
                5
               </div>
               <div class="crayon-num crayon-striped-num" data-line="crayon-57685db75c949771156733-6">
                6
               </div>
              </div>
             </td>
             <td class="crayon-code">
              <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
               <div class="crayon-line" id="crayon-57685db75c949771156733-1">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &amp;
                </span>
                <span class="crayon-v">
                 gt
                </span>
                <span class="crayon-sy">
                 ;
                </span>
                <span class="crayon-o">
                 &amp;
                </span>
                <span class="crayon-v">
                 gt
                </span>
                <span class="crayon-sy">
                 ;
                </span>
                <span class="crayon-o">
                 &amp;
                </span>
                <span class="crayon-v">
                 gt
                </span>
                <span class="crayon-sy">
                 ;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 r
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;=
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-e">
                 recommender
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 0
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c949771156733-2">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &amp;
                </span>
                <span class="crayon-v">
                 gt
                </span>
                <span class="crayon-sy">
                 ;
                </span>
                <span class="crayon-o">
                 &amp;
                </span>
                <span class="crayon-v">
                 gt
                </span>
                <span class="crayon-sy">
                 ;
                </span>
                <span class="crayon-o">
                 &amp;
                </span>
                <span class="crayon-v">
                 gt
                </span>
                <span class="crayon-sy">
                 ;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 r
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 loadMovieLens
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 '&lt;/span&gt;/Users/raz/Downloads/ml-100k/&lt;span class="pl-pds"&gt;'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c949771156733-3">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 102625
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c949771156733-4">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &amp;
                </span>
                <span class="crayon-v">
                 gt
                </span>
                <span class="crayon-sy">
                 ;
                </span>
                <span class="crayon-o">
                 &amp;
                </span>
                <span class="crayon-v">
                 gt
                </span>
                <span class="crayon-sy">
                 ;
                </span>
                <span class="crayon-o">
                 &amp;
                </span>
                <span class="crayon-v">
                 gt
                </span>
                <span class="crayon-sy">
                 ;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 r
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 computeDeviations
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-p">
                 # 大约需要50秒&lt;/span&gt;
                </span>
               </div>
               <div class="crayon-line" id="crayon-57685db75c949771156733-5">
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-k"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &amp;
                </span>
                <span class="crayon-v">
                 gt
                </span>
                <span class="crayon-sy">
                 ;
                </span>
                <span class="crayon-o">
                 &amp;
                </span>
                <span class="crayon-v">
                 gt
                </span>
                <span class="crayon-sy">
                 ;
                </span>
                <span class="crayon-o">
                 &amp;
                </span>
                <span class="crayon-v">
                 gt
                </span>
                <span class="crayon-sy">
                 ;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-v">
                 r
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-e">
                 slopeOneRecommendations
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-v">
                 r
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-v">
                 data
                </span>
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 '&lt;/span&gt;25&lt;span class="pl-pds"&gt;'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ]
                </span>
                <span class="crayon-sy">
                 )
                </span>
               </div>
               <div class="crayon-line crayon-striped-line" id="crayon-57685db75c949771156733-6">
                <span class="crayon-sy">
                 [
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 '&lt;/span&gt;Aiqing wansui (1994)&lt;span class="pl-pds"&gt;'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 5.674418604651163
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 (
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-s1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-pds"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-s">
                 '&lt;/span&gt;Boys, Les (1997)&lt;span class="pl-pds"&gt;'
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-e">
                 span
                </span>
                <span class="crayon-t">
                 class
                </span>
                <span class="crayon-o">
                 =
                </span>
                <span class="crayon-s">
                 "pl-c1"
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-cn">
                 5.523076923076923
                </span>
                <span class="crayon-o">
                 &lt;
                </span>
                <span class="crayon-o">
                 /
                </span>
                <span class="crayon-v">
                 span
                </span>
                <span class="crayon-o">
                 &gt;
                </span>
                <span class="crayon-sy">
                 )
                </span>
                <span class="crayon-sy">
                 ,
                </span>
                <span class="crayon-h">
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-sy">
                 .
                </span>
                <span class="crayon-sy">
                 ]
                </span>
               </div>
              </div>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
        <!-- [Format Time: 0.0277 seconds] -->
       </div>
       <p>
        <strong>
         作业
        </strong>
       </p>
       <ol class="task-list">
        <li>
         看看Slope One的推荐结果是否靠谱：对数据集中的10部电影进行评分，得到的推荐结果是否是你喜欢的电影呢？
        </li>
        <li>
         实现修正的余弦相似度算法，比较一下两者的运算效率。
        </li>
        <li>
         （较难）我的笔记本电脑有8G内存，在尝试用Slope One计算图书漂流站数据集时报内存溢出了。那个数据集中有27万本书，因此需要保存超过7300万条记录的Python字典。这个字典的数据是否很稀疏呢？修改算法，让它能够处理更多数据吧。
        </li>
       </ol>
       <p>
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/img/chapter-3/chapter-3-50.png" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/chapter-3-50.png"/>
        </a>
       </p>
       <p>
        <strong>
         祝贺大家学完第三章了
        </strong>
       </p>
       <p>
       </p>
       <p>
        英文原文：
        <a href="http://guidetodatamining.com/chapter-3/">
         http://guidetodatamining.com/chapter-3/
        </a>
       </p>
       <p>
        原文出处：
        <a href="https://github.com/jizhang/guidetodatamining/blob/master/chapter-3.md">
         https://github.com/jizhang/guidetodatamining/blob/master/chapter-3.md
        </a>
       </p>
      </div>
      <div>
       <strong>
        注：转载文章均来自于公开网络，仅供学习使用，不会用于任何商业用途，如果侵犯到原作者的权益，请您与我们联系删除或者授权事宜，联系邮箱：contact@dataunion.org。转载数盟网站文章请注明原文章作者，否则产生的任何版权纠纷与数盟无关。
       </strong>
      </div>
      <!--content_text-->
      <div class="fenxian">
       <!-- JiaThis Button BEGIN -->
       <div class="jiathis_style_32x32">
        <p class="jiathis_button_weixin">
        </p>
        <p class="jiathis_button_tsina">
        </p>
        <p class="jiathis_button_qzone">
        </p>
        <p class="jiathis_button_cqq">
        </p>
        <p class="jiathis_button_tumblr">
        </p>
        <a class="jiathis jiathis_txt jtico jtico_jiathis" href="http://www.jiathis.com/share" target="_blank">
        </a>
        <p class="jiathis_counter_style">
        </p>
       </div>
       <!-- JiaThis Button END -->
      </div>
     </article>
     <!--content-->
     <!--相关文章-->
     <div class="xianguan">
      <div class="xianguantitle">
       相关文章！
      </div>
      <ul class="pic">
       <li>
        <a href="http://dataunion.org/20824.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/09/t018630756a7e263b33-300x165.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/20824.html" rel="bookmark" title="如何判断一笔交易是否属于欺诈？你只是需要一点数据挖掘">
         如何判断一笔交易是否属于欺诈？你只是需要一点数据挖掘
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/20679.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/09/t010e3a70fbcfef2c12-300x101.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/20679.html" rel="bookmark" title="一篇文章带你认识“高大上”的图数据挖掘">
         一篇文章带你认识“高大上”的图数据挖掘
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/20167.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/07/t0170189d0bb57172e9_副本.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/20167.html" rel="bookmark" title="浅谈金融行业的数据挖掘之道">
         浅谈金融行业的数据挖掘之道
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/19877.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/07/t01d360f079b2c02f4d.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/19877.html" rel="bookmark" title="想入门机器学习、数据挖掘，我该怎么做？">
         想入门机器学习、数据挖掘，我该怎么做？
        </a>
       </li>
      </ul>
     </div>
     <!--相关文章-->
     <div class="comment" id="comments">
      <!-- You can start editing here. -->
      <!-- If comments are open, but there are no comments. -->
      <div class="title">
       期待你一针见血的评论，Come on！
      </div>
      <div id="respond">
       <p>
        不用想啦，马上
        <a href="http://dataunion.org/wp-login.php?redirect_to=http%3A%2F%2Fdataunion.org%2F8082.html">
         "登录"
        </a>
        发表自已的想法.
       </p>
      </div>
     </div>
     <!-- .nav-single -->
    </div>
    <!--Container End-->
    <aside id="sitebar">
     <div class="sitebar_list2">
      <div class="wptag">
       <span class="tagtitle">
        热门标签+
       </span>
       <div class="tagg">
        <ul class="menu" id="menu-%e5%8f%8b%e6%83%85%e9%93%be%e6%8e%a5">
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1605" id="menu-item-1605">
          <a href="http://taidizh.com/">
           泰迪智慧
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20884" id="menu-item-20884">
          <a href="http://www.transwarp.cn/">
           星环科技
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-3538" id="menu-item-3538">
          <a href="http://datall.org/">
           珈和遥感
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20888" id="menu-item-20888">
          <a href="http://www.chinahadoop.cn/">
           小象学院
          </a>
         </li>
        </ul>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <div class="textwidget">
       <div align="center">
        <a href="http://study.163.com/course/courseMain.htm?courseId=991022" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2016/03/dv.jpg"/>
        </a>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       文章分类
      </h4>
      <div class="tagcloud">
       <a class="tag-link-44" href="http://dataunion.org/category/industry/demo" style="font-size: 10.204724409449pt;" title="4个话题">
        Demo展示
       </a>
       <a class="tag-link-31" href="http://dataunion.org/category/experts" style="font-size: 15.826771653543pt;" title="52个话题">
        专家团队
       </a>
       <a class="tag-link-870" href="http://dataunion.org/category/tech/ai" style="font-size: 19.795275590551pt;" title="273个话题">
        人工智能
       </a>
       <a class="tag-link-488" href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f" style="font-size: 8pt;" title="1个话题">
        加入数盟
       </a>
       <a class="tag-link-869" href="http://dataunion.org/category/tech/viz" style="font-size: 17.204724409449pt;" title="93个话题">
        可视化
       </a>
       <a class="tag-link-30" href="http://dataunion.org/category/partners" style="font-size: 10.645669291339pt;" title="5个话题">
        合作伙伴
       </a>
       <a class="tag-link-889" href="http://dataunion.org/category/parterc" style="font-size: 11.582677165354pt;" title="8个话题">
        合作会议
       </a>
       <a class="tag-link-104" href="http://dataunion.org/category/books" style="font-size: 12.96062992126pt;" title="15个话题">
        图书
       </a>
       <a class="tag-link-220" href="http://dataunion.org/category/tech/base" style="font-size: 19.850393700787pt;" title="281个话题">
        基础架构
       </a>
       <a class="tag-link-219" href="http://dataunion.org/category/tech/analysis" style="font-size: 19.409448818898pt;" title="232个话题">
        数据分析
       </a>
       <a class="tag-link-887" href="http://dataunion.org/category/tech/dm" style="font-size: 13.291338582677pt;" title="17个话题">
        数据挖掘
       </a>
       <a class="tag-link-34" href="http://dataunion.org/category/tech" style="font-size: 20.732283464567pt;" title="404个话题">
        文章
       </a>
       <a class="tag-link-1" href="http://dataunion.org/category/uncategorized" style="font-size: 22pt;" title="693个话题">
        未分类
       </a>
       <a class="tag-link-4" href="http://dataunion.org/category/events" style="font-size: 14.503937007874pt;" title="29个话题">
        活动
       </a>
       <a class="tag-link-890" href="http://dataunion.org/category/tech/%e6%b7%b1%e5%ba%a6%e5%ad%a6%e4%b9%a0" style="font-size: 10.204724409449pt;" title="4个话题">
        深度学习
       </a>
       <a class="tag-link-221" href="http://dataunion.org/category/tech/devl" style="font-size: 18.968503937008pt;" title="193个话题">
        编程语言
       </a>
       <a class="tag-link-888" href="http://dataunion.org/category/career" style="font-size: 15.661417322835pt;" title="48个话题">
        职业规划
       </a>
       <a class="tag-link-5" href="http://dataunion.org/category/jobs" style="font-size: 14.11811023622pt;" title="25个话题">
        职位
       </a>
       <a class="tag-link-871" href="http://dataunion.org/category/industry" style="font-size: 15.716535433071pt;" title="49个话题">
        行业
       </a>
       <a class="tag-link-613" href="http://dataunion.org/category/industry/case" style="font-size: 16.984251968504pt;" title="84个话题">
        行业应用
       </a>
       <a class="tag-link-885" href="http://dataunion.org/category/industry/news" style="font-size: 17.425196850394pt;" title="102个话题">
        行业资讯
       </a>
       <a class="tag-link-10" href="http://dataunion.org/category/training" style="font-size: 14.228346456693pt;" title="26个话题">
        课程
       </a>
       <a class="tag-link-16" href="http://dataunion.org/category/sources" style="font-size: 15.661417322835pt;" title="48个话题">
        资源
       </a>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       功能
      </h4>
      <ul>
       <li>
        <a href="http://dataunion.org/wp-login.php?action=register">
         注册
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/wp-login.php">
         登录
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/feed">
         文章
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/comments/feed">
         评论
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="https://cn.wordpress.org/" title="基于WordPress，一个优美、先进的个人信息发布平台。">
         WordPress.org
        </a>
       </li>
      </ul>
     </div>
    </aside>
    <div class="clear">
    </div>
   </div>
   <!--main-->
   ﻿
   <footer id="dibu">
    <div class="about">
     <div class="right">
      <ul class="menu" id="menu-%e5%ba%95%e9%83%a8%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-18024" id="menu-item-18024">
        <a href="http://dataunion.org/category/partners">
         合作伙伴
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20881" id="menu-item-20881">
        <a href="http://dataunion.org/contribute">
         文章投稿
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20872" id="menu-item-20872">
        <a href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f">
         加入数盟
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22441" id="menu-item-22441">
        <a href="http://dataunion.org/f-links">
         友情链接
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20874" id="menu-item-20874">
        <a href="http://dataunion.org/aboutus">
         关于数盟
        </a>
       </li>
      </ul>
      <p class="banquan">
       数盟社区        ，
        做最棒的数据科学社区
      </p>
     </div>
     <div class="left">
      <ul class="bottomlist">
       <li>
        <a href="http://weibo.com/DataScientistUnion  " target="_blank" 　title="">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weibo.png"/>
        </a>
       </li>
       <li>
        <a class="cd-popup-trigger" href="http://dataunion.org/8082.html#0">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weixin.png"/>
        </a>
       </li>
      </ul>
      <div class="cd-popup">
       <div class="cd-popup-container">
        <h1>
         扫描二维码,加微信公众号
        </h1>
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/2014-12-06-1515289049.png"/>
        <a class="cd-popup-close" href="http://dataunion.org/8082.html">
        </a>
       </div>
       <!-- cd-popup-container -->
      </div>
      <!-- cd-popup -->
     </div>
    </div>
    <!--about-->
    <div class="bottom">
     <a href="http://dataunion.org/">
      数盟社区
     </a>
     <a href="http://www.miitbeian.gov.cn/" rel="external nofollow" target="_blank">
      京ICP备14026740号
     </a>
     联系我们：
     <a href="mailto:contact@dataunion.org" target="_blank">
      contact@dataunion.org
     </a>
     <div class="tongji">
     </div>
     <!--bottom-->
     <div class="scroll" id="scroll" style="display:none;">
      ︿
     </div>
    </div>
   </footer>
   <!--dibu-->
  </div>
 </body>
</html>